﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sparrow.Globalization
{
    public class Element
    {
     
        public string Name
        {
            get;
            set;
        }

        public string Value
        {
            get;
            set;
        }

        public string Category
        {
            get;
            set;
        }

        public string Culture
        {
            get;
            set;
        }
    
        public override string ToString()
        {
            return this.Value;
        }

        #region equals
        public static bool operator ==(Element obj1, Element obj2)
        {
            var obj1IsNull = object.Equals(obj1, null);
            var obj2IsNull = object.Equals(obj2, null);

            if (obj1IsNull && obj2IsNull)
            {
                return true;
            }
            else if (obj1IsNull == false && obj2IsNull == false)
            {
                return obj1.Name == obj2.Name && obj1.Culture == obj2.Culture && obj1.Category == obj2.Category;
            }
            else
            {
                return object.Equals(obj1, obj2);
            }
        }

        public static bool operator !=(Element obj1, Element obj2)
        {
            var obj1IsNull = object.Equals(obj1, null);
            var obj2IsNull = object.Equals(obj2, null);

            if (obj1IsNull && obj2IsNull)
            {
                return false;
            }
            else if (obj1IsNull == false && obj2IsNull == false)
            {
                return obj1.Name != obj2.Name || obj1.Culture != obj2.Culture || obj1.Category != obj2.Category;
            }
            else
            {
                return object.Equals(obj1, obj2) == false;
            }
        }

        public override bool Equals(object obj)
        {

            if (object.Equals(obj, null))
            {
                return false;
            }

            var el = obj as Element;
            if (el == null)
            {
                return base.Equals(obj);
            }
            else
            {
                return el.Name == this.Name && el.Culture == this.Culture && el.Category == this.Category;
            }


        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        } 
        #endregion
    }
}
